package com.yishusmt.mobsmt.controller;

import com.yishusmt.mobsmt.check.DataCheck;
import com.yishusmt.mobsmt.dto.base.Result;
import com.yishusmt.mobsmt.dto.request.UserRegisterReq;
import com.yishusmt.mobsmt.service.RegisterService;
import com.yishusmt.mobsmt.utils.ResultUtil;
import com.yishusmt.mobsmt.utils.TipsUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * 用户注册
 *
 * @author zhangyi
 * @date 2018/8/9 11:48
 */
@RestController
@Api(description = "用户注册控制")
@RequestMapping("/userRegister")
public class UserRegisterController {

    @Resource
    private RegisterService registerService;

    /**
     * 用户注册验证码
     *
     * @param userRegisterReq
     * @return
     */
    @PostMapping("/register")
    @ApiOperation(value = "用户注册",httpMethod = "POST")
    public Result register(@RequestBody UserRegisterReq userRegisterReq){
        DataCheck.isNull(userRegisterReq);
        return registerService.register(userRegisterReq);
    }

    /**
     * 查询当前用户信息
     *
     * @param phone
     * @return
     */
    @GetMapping("/selectNowUser/{phone}")
    @ApiOperation(value = "查询当前用户信息",httpMethod = "GET")
    public Result selectNowUser(@PathVariable("phone") String phone){
        DataCheck.isNull(phone);
        return registerService.selectNowUser(phone);
    }
}
